#ifndef MAINWINDOW_HPP
#define MAINWINDOW_HPP

#include <QMainWindow>
#include <QGridLayout>
#include <QList>
#include <QHash>

#include "connexion.hpp"
#include "reseau.hpp"
#include "lobby.hpp"
#include "game.hpp"

class Lobby;
class Game;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

    QList<Game *> gameList() const;

private:
    QGridLayout * _layout;

    Connexion * _connexion;
    Reseau * _reseau;
    Lobby * _lobby;
    QHash<quint8, Game *> _gameHash;

public slots:
    void reactConnectionSuccess();
    void reactConnectionFailed(int port);
    void reactCreateGame(quint8 goban, qreal komi);
    void reactGameDestroy(quint8 id);
    void reactGameQuit(quint8 id);

    void destroyGame(quint8 id);

    void reactWantToSee(quint8 id);
    void reactWantToPlay(quint8 id);

    void reactDontWantToSeeAnymore(quint8 id);

    void reactGameSay(quint8 id, const QString & message);

    void reactPlayMove(quint8 id, quint8 x, quint8 y);
    void reactSkipTurn(quint8 id);

    void reactDeadGroup(quint8 id, quint8 x, quint8 y);
    void reactAliveGroup(quint8 id, quint8 x, quint8 y);

    void reactToPlay(quint8 id);
    void reactValidateGroups(quint8 id);

private slots:
    void displayLobby();
};

#endif // MAINWINDOW_HPP
